home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.m68k
- Path: netcom.com!ludis
- From: ludis@netcom.com (Ludis Langens)
- Subject: Re: how to convert locical to physical address on 68040
- Message-ID: <ludisDLMsKv.344@netcom.com>
- Organization: It's here somewhere
- References: <Pine.SOL.3.91.960122210823.17385A-100000@emmi.physik.TU-Berlin.DE>
- Date: Tue, 23 Jan 1996 11:14:55 GMT
- Sender: ludis@netcom9.netcom.com
-
- In article <Pine.SOL.3.91.960122210823.17385A-100000@emmi.physik.TU-Berlin.DE> Peter Kelm <kelm@emmi.physik.TU-Berlin.DE> writes:
- >Hello,
- >I need to convert a given logical address into a physical one (I am
- >programming on a macintosh but the code of course is only processor
- >dependent). The problem behind is to examine how the MacOS has mapped
- >itself (to get NetBSD un*x running on a 040). Read all of the literature I
- >could get (for example M68040 Users Manual). But my code still fails.
- >
- >This is what I tried:
- >1) use "ptestr (a0)" wit the logical address in a0. The get the mmusr
- >(movec mmusr,d0), extract the address part and put it together with a
- >part of the logical address to form the physical.
- >2) -get mmu root pointer
- > -do the table walk by hand (get TIA part - form root level table
- >descriptor, get TIB part, ...)
- >
- >The processor is in supervisor mode.
- >Has anyone out there a working address conversion code or a URL pointer
- >to such a source code fragment ???
-
- Either method you tried probably should work. However, for method 2,
- all the mmu pointers are physical addresses. Because you don't know
- the LtoP (or PtoL) translation, you can't read the mmu tables! There
- are various tricks (such as alternative function code spaces) to get
- around this problem. Because all these tricks depend on the OS and/or
- system hardware configuration, this is not a portable solution.
-
- Are you really in supervisor mode? Mac VM fakes supervisor mode (by
- emulating certain priviledged instructions).
-
- The MacOS provides a function that gives you the physical addresses
- for a range of logical addresses. (This is meant for use with DMA
- devices and so on.)
-
- The memory location DDC (I think) points at a data structure that decribes
- the memory layout. (The structure is mostly at negative offsets from
- the pointer. The MMU tables are also located in this memory range.)
- When Apple's VM loads, it will use the data here to create its own (new)
- mmu tables.
-
- To help you read the non-VM mmu tables, location 1EF8 (I think) contains
- the PtoL address offset for the mmu table itself. (Add the value to
- the physical address to get the logical...) This only works if the
- tables are contiguous... (which they are).
-
- --
- unsigned long BinToBCD(unsigned long i) {unsigned long t;
- Ludis Langens return i ? (t = BinToBCD(i >> 1), (t << 1) + (i & 1) +
- ludis@netcom.com (t + 858993459 >> 2 & 572662306) * 3) : 0;}
-